package tds.model2.version2;

import java.math.BigDecimal;

/**
 * 
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName CashContext
 * @Description TODO(收费上下文)
 * @author tds
 * @Date 2019年1月7日 下午12:41:36
 * @version 1.0.0
 */
public class CashContext {
	
	private CashSuper cashSuper = null;
	
	public CashContext(CashType type){
		switch (type) {
			case NOMAL:
				cashSuper = new CashNomal();
				break;
			case SIX_DISCOUNT:
				cashSuper = new CashDiscount(new BigDecimal("0.6"));
				break;
			case EIGHT_DISCOUNT:
				cashSuper = new CashDiscount(new BigDecimal("0.8"));
				break;
			case NINE_DISCOUNT:
				cashSuper = new CashDiscount(new BigDecimal("0.9"));
				break;
			case CONDITION_RETURN:
				cashSuper = new CashReturn(new BigDecimal("300"), new BigDecimal("100"));
				break;
	
			default:
				throw new RuntimeException("未知的营销策略");
		}
	}
	
	public BigDecimal getResult(BigDecimal money){
		return cashSuper.calculateActualMoney(money);
	}
}
